﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyProspect.aspx.cs" Inherits="ValuationClient.ProjectProspect.MyProspect" %>


<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Basic DataGrid - jQuery EasyUI Demo</title>
   <link href="../jquery-easyui-1.5.2/themes/default/easyui.css" rel="stylesheet" />
    <link href="../jquery-easyui-1.5.2/themes/icon.css" rel="stylesheet" />
    <script src="../jquery-easyui-1.5.2/jquery.min.js"></script>
    <script src="../jquery-easyui-1.5.2/jquery.easyui.min.js"></script>
    <script src="../jquery-easyui-1.5.2/easyloader.js"></script>
    <script src="../jquery-easyui-1.5.2/jquery.params.js"></script>
</head>
<body>
    <div style="padding:10px">
          <%-- <input type="text" hidden="hidden" id="username" value="<%=Request["username"]%>" />--%>
        <select class="easyui-combobox" id="select1" style="width:150px;">
            <option value="0">---请选择----</option>
            <option value="1">所属部门</option>
            <option value="2">项目号</option>
            <option value="3">借款人</option>
            <option value="4">房屋坐落</option>
        </select>
        <select class="easyui-combobox" id="select2" style="width:150px;">
            <option value="0">----请选择----</option>
        </select>
        <a href="#" class="easyui-linkbutton" plain="true" onclick="SelctBasic1()" data-options="iconCls:'icon-search'"  style="width: 80px; margin-bottom: 2px; margin-left: 10px; border: solid 1px #c0f6ef")">查询</a>
    </div>
    <div>
        
       <a href="javascript:void(0) " class="easyui-linkbutton" onclick="quwei()">区位状况勘察</a>&nbsp;
        <a href="javascript:void(0) " class="easyui-linkbutton" onclick="xiaoqu()">小区状况勘察</a>&nbsp;
        <a href="javascript:void(0) " class="easyui-linkbutton" onclick="lou()">楼状况勘察</a>&nbsp;
             <a href="javascript:void(0)" class="easyui-linkbutton" onclick="indoor()">室内勘察</a>&nbsp;
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="Photo()">现场照片提供</a>&nbsp;
        <a href="javascript:void(0) " class="easyui-linkbutton" onclick="xunjia()">询价记录</a>&nbsp;
        <a href="javascript:void(0) " class="easyui-linkbutton" onclick="xiang()">详情</a>&nbsp;
        <a href="javascript:void(0) " class="easyui-linkbutton">审核详情</a>&nbsp;


    </div>
    <!---- 显示项目信息---->
    <div>
        <table id="dg" class="easyui-datagrid" toolbar="#tb">
        </table>
    </div>
</body>
</html>
<script>
    $(function () {
        SelctBasic();
    })

    //显示贷款列表
    function SelctBasic() {

        var id = $("#select1").combobox('getValue');
        //var name = $("#select2").combobox('getValue');
        $.ajax({
            type: "get",
            url: "http://localhost:55439/api/Project/GetBasicInfo/?id=" + id + "&name=" + name,
            dataType: "json",
            success: function (obj) {
                obj = eval(obj);
                $("#dg").datagrid({
                    pagination: true,
                    data: obj.slice(0, 10),
                    striped: true,
                    columns: [[
                        { field: 'ck', checkbox: true },
                        {
                            field: "projectNumber", width: 100, title: '项目编号', align: 'center',
                            formatter: function (value, row, index) {
                                return '<a style="color:blue" href="#">' + row.projectNumber + '</a>';
                            }
                        },
                        { field: "the_Department", width: 100, title: '所属部门', align: 'center' },
                        { field: "loan_Name", width: 100, title: '借款人', align: 'center' },
                        { field: "loan_TEL", width: 100, title: '借款人联系电话', align: 'center' },
                        { field: "basic_Quota", width: 100, title: '贷款额度', align: 'center' },
                        { field: "RegisterTime", width: 150, title: '登记时间', align: 'center' },
                         {
                             field: "basic_State", width: 150, title: '项目状态', align: 'center',
                             formatter: function (value, row, index) {
                                 ///也可用 formatter: function (value, rec) {
                                 return row.basic_State == 0 ? '待勘察' : row.basic_State == 1 ? "勘察中" : row.basic_State == 2 ? "待审核" : row.basic_State == 3 ? "初审核中" : row.basic_State == 4 ? "终审通过" : ""
                             }
                         },
                    ]]
                });
                var pager = $("#dg").datagrid("getPager");
                pager.pagination({
                    beforePageText: '第',//页数文本框前显示的汉字 
                    afterPageText: '页 共 {pages} 页',
                    displayMsg: '共{total}条数据',
                    total: obj.length,
                    onSelectPage: function (pageNo, pageSize) {
                        var start = (pageNo - 1) * pageSize;
                        var end = start + pageSize;
                        $("#dg").datagrid("loadData", obj.slice(start, end));
                        pager.pagination('refresh', {
                            total: obj.length,
                            pageNumber: pageNo
                        });
                    }
                });
            }
        })
    }
    //查询
    function SelctBasic1() {
        var id = $("#select1").combobox('getValue');
        var name = $("#select2").combobox('getText');
        $.ajax({
            type: "get",
            url: "http://localhost:55439/api/Project/GetBasicInfo/?id=" + id + "&name=" + name,
            dataType: "json",
            success: function (obj) {
                obj = eval(obj);
                $("#dg").datagrid({
                    pagination: true,
                    data: obj.slice(0, 10),
                    striped: true,
                    columns: [[
                        { field: 'ck', checkbox: true },
                        {
                            field: "projectNumber", width: 100, title: '项目编号', align: 'center',
                            formatter: function (value, row, index) {
                                return '<a style="color:blue" href="#">' + row.projectNumber + '</a>';
                            }
                        },
                        { field: "the_Department", width: 100, title: '所属部门', align: 'center' },
                        { field: "loan_Name", width: 100, title: '借款人', align: 'center' },
                        { field: "loan_TEL", width: 100, title: '借款人联系电话', align: 'center' },
                        { field: "basic_Quota", width: 100, title: '贷款额度', align: 'center' },
                        { field: "RegisterTime", width: 150, title: '登记时间', align: 'center' },
                         {
                             field: "basic_State", width: 150, title: '项目状态', align: 'center',
                             formatter: function (value, row, index) {
                                 ///也可用 formatter: function (value, rec) {
                                 return row.basic_State == 0 ? '待勘察' : row.basic_State == 1 ? "勘察中" : row.basic_State == 2 ? "待审核" : row.basic_State == 3 ? "初审核中" : row.basic_State == 4 ? "终审通过" : ""
                             }
                         },
                    ]]
                });
                //分页
                var pager = $("#dg").datagrid("getPager");
                pager.pagination({
                    beforePageText: '第',//页数文本框前显示的汉字 
                    afterPageText: '页 共 {pages} 页',
                    displayMsg: '共{total}条数据',
                    total: obj.length,
                    onSelectPage: function (pageNo, pageSize) {
                        var start = (pageNo - 1) * pageSize;
                        var end = start + pageSize;
                        $("#dg").datagrid("loadData", obj.slice(start, end));
                        pager.pagination('refresh', {
                            total: obj.length,
                            pageNumber: pageNo
                        });
                    }
                });
            }
        })
    }
    //下拉联动
    $("#select1").combobox({
        onChange: function () {
            var id = $("#select1").combobox('getValue');
            //所属部门
            if (id == 1) {
                $.ajax({
                    type: "get",
                    url: "http://localhost:55439/api/Project/SelectBasic",
                    async: false,
                    success: function (obj) {
                        obj = eval(obj);
                        $("#select2").combobox({
                            data: obj,
                            valueField: 'Department_Id',
                            textField: 'Department_Name',
                            onLoadSuccess: function () {
                                $("#select2").combobox('select', '-----请选择-----');
                            }
                        })
                    }
                })
            }
            //项目号
            if (id == 2) {
                $.ajax({
                    type: "get",
                    url: "http://localhost:55439/api/Project/SelectBasic",
                    async: false,
                    success: function (obj) {
                        obj = eval(obj);
                        $("#select2").combobox({
                            data: obj,
                            valueField: 'basic_id',
                            textField: 'projectNumber',
                            onLoadSuccess: function () {
                                $("#select2").combobox('select', '-----请选择-----');
                            }
                        })
                    }
                })
            }
            //借款人
            if (id == 3) {
                $.ajax({
                    type: "get",
                    url: "http://localhost:55439/api/Project/SelectBasic",
                    async: false,
                    success: function (obj) {
                        obj = eval(obj);
                        $("#select2").combobox({
                            data: obj,
                            valueField: 'loan_Name',
                            textField: 'loan_Name',
                            onLoadSuccess: function () {
                                $("#select2").combobox('select', '-----请选择-----');
                            }
                        })
                    }
                })
            }
            //房屋坐落
            if (id == 4) {
                $.ajax({
                    type: "get",
                    url: "http://localhost:55439/api/Project/SelectBasic",
                    async: false,
                    success: function (obj) {
                        obj = eval(obj);
                        $("#select2").combobox({
                            data: obj,
                            valueField: 'house_Located',
                            textField: 'house_Located',
                            onLoadSuccess: function () {
                                $("#select2").combobox('select', '-----请选择-----');
                            }
                        })
                    }
                })
            }
        }
    })

    //跳转详情页面
    function datalis(domeId) {
        parent.addTab("详细信息", "/ProjectProspect/PublicSituation.aspx?id=" + domeId, "icon-chart-organisation", true);
    }

    //跳转详情页面
    function xiang() {
        var chek = "";
        $(":checkbox:checked").each(function () {
            chek += $(this).val();
        })
        //if (chek.length != 1) {
        //    $.messager.alert("", "每次只能勘察一个项目！");
        //}
        //else {
        var xiangId = $(":checkbox:checked").parent().parent().parent().children().eq(1).children().children().html();
        parent.addTab("详细信息", "/ProjectProspect/Particulars.aspx?id=" + xiangId, "icon-chart-organisation", true);
        //}
    }

    //跳转楼状况勘察
    function lou() {
        var chek = "";
        $(":checkbox:checked").each(function () {
            chek += $(this).val();
        })
        //if (chek.length != 1) {
        //    $.messager.alert("", "每次只能勘察一个项目！");
        //}
        //else {
        var xiangId = $(":checkbox:checked").parent().parent().parent().children().eq(1).children().children().html();
        parent.addTab("建筑公共部分状况勘察", "/ProjectProspect/PublicSituation.aspx?id=" + xiangId, "icon-chart-organisation", true);
        //}
    }

    //跳转小区状况勘察
    function xiaoqu() {
        var chek = "";
        $(":checkbox:checked").each(function () {
            chek += $(this).val();
        })
        //if (chek.length != 1) {
        //    $.messager.alert("", "每次只能勘察一个项目！");
        //}
        //else {
        var xiangId = $(":checkbox:checked").parent().parent().parent().children().eq(1).children().children().html();
        parent.addTab("小区状况勘察", "/ProjectProspect/RegionalStatus.aspx?id=" + xiangId, "icon-chart-organisation", true);
        //}
    }

    //跳转询价页面
    function xunjia() {
        var chek = "";
        $(":checkbox:checked").each(function () {
            chek += $(this).val();
        })
        //if (chek.length != 1) {
        //    $.messager.alert("", "每次只能勘察一个项目！");
        //}
        //else {
        var xiangId = $(":checkbox:checked").parent().parent().parent().children().eq(1).children().children().html();
        parent.addTab("询价列表", "/ProjectProspect/InquiryRecords.aspx?id=" + xiangId, "icon-chart-organisation", true);
        //}
    }


    //跳转室内勘察页面
    function indoor() {
        var chek = "";
        $(":checkbox:checked").each(function () {
            chek += $(this).val();
        })
        //if (chek.length != 1) {
        //    $.messager.alert("", "每次只能勘察一个项目！");
        //}
        //else {
        var xiangId = $(":checkbox:checked").parent().parent().parent().children().eq(1).children().children().html();
        parent.addTab("室内勘察", "/ProjectProspect/IndoorConditions.aspx?id=" + xiangId, "icon-chart-organisation", true);
        //}
    }
    //跳转现场照片提供页面
    function Photo() {
        var chek = "";
        $(":checkbox:checked").each(function () {
            chek += $(this).val();
        })
        //if (chek.length != 1) {
        //    $.messager.alert("", "每次只能勘察一个项目！");
        //}
        //else {
        var xiangId = $(":checkbox:checked").parent().parent().parent().children().eq(1).children().children().html();
        parent.addTab("现场照片提供", "/ProjectProspect/Scene.aspx?id=" + xiangId, "icon-chart-organisation", true);
        //}
    }


    ///区位勘察
    function quwei() {
        var chek = "";
        $(":checkbox:checked").each(function () {
            chek += $(this).val();
        })
        //if (chek.length != 1) {
        //    $.messager.alert("", "每次只能勘察一个项目！");
        //}
        //else {
        var xiangId = $(":checkbox:checked").parent().parent().parent().children().eq(1).children().children().html();
        parent.addTab("区位状况勘察", "/ProjectProspect/CommunityStatus.aspx?id=" + xiangId, "icon-chart-organisation", true);
        //}

    }

    //结束勘察
    function jieshu(id) {
        $.ajax({
            type: "post", //要用post方式                 
            url: "Domelist.aspx/updState",//方法所在页面和方法名
            contentType: "application/json; charset=utf-8",
            data: "{'id':'" + id + "'}",
            dataType: "json",
            success: function (result) {
                if (result) {
                    $.messager.alert("结束勘察", "操作成功");
                }


            }
        });
    }

</script>

